first commit
just tested to work fine but need refactoring.