intial working version, bugs fixed