Refactor and moved to Spring framework