Changed code regarding to new API