reduce complexity & improve code