edited for compatibility