Tamird/refactor

@hassox plz to review