working alpha version, ready for refactoring