Use layer functions instead of type casting