functions swaped + minor bugfixes