finally got it working

changed all code to work