changed code to work with 2.4
reverted last commit