first version working with bugs