A method for solving contact problems