added class check in all functions