got rid of useless code and added comments