30.07.2013 refactored and repaired