corrected a Bug, added a function