better implementation and updated readme