Converted to modular php structure