added rake file and cleaned up code