added login and fixed few bugs