Added code from RTS repo