Fixing error about return value and cleaning