commented and cleaned up. still needs queue