made code generic