Rewrite code for getting properties and improve style