Refactored to plain php
Refactored