Setting up general framework for solving the problem. Crappy implmeentaiton