added changes to make it work better