finally got the basic right