fixed #31 has to be refactored