clearned up the code