Static types added and readability improved