added edge detection