fixing couple of bugs