fixed bugs and logical errors
namesake commit