Refactoring & db requests optimization